// TranslationService.js
import axios from 'axios'
import { util } from 'echarts'
// import enTranslations from './en.js'
// import ruTranslations from './ru.js'

const TRANSLATION_API_URL = '/translations'

export default class TranslationService {
    constructor() {
        this.translations = {
            // 'en': enTranslations,
            // 'ru': ruTranslations
        }
    }

    async loadTranslation() {
        const response = await axios.get(`${TRANSLATION_API_URL}`)
        this.translations = response.data
    }

    //优化传参中不包含 zh的情况
    translate(text, lang) {
        if (this.translations[lang] && this.translations[lang][text]) {
            return this.translations[lang][text]
        } else {
            return text
        }
    }


}